package com.imooc.juc;

import java.util.ArrayList;
import java.util.UUID;

/** 线程不安全演示
 * @Date:2021/10/31/11:12
 * @Description:
 */
public class NoSafeDemo {
    public static void main(String[] args) {

        ArrayList arrayList = new ArrayList();

        for (int i = 0; i < 30; i++) {

            new Thread( () ->{   //懒蛋表达式，需要注意的是 3个线程是同时进行的
                arrayList.add(UUID.randomUUID().toString().substring(0, 5));
                System.out.println(arrayList);

            },String.valueOf(i) ).start();
        }


    }
}
